from domain.cellResultMap import CellResultMap


class TotalResult:
    """
    总结果集对象
    """

    def __init__(self):
        pass

    def calculate_result(self):
        """
        计算最终数据
        """

        # 单个城市
        k: str
        v: CellResultMap
        for k, v in self.__dict__.items():
            # print(k, v.unconnected_rate, v.node_count, v.rrc_and_e_rab_node_count)
            v.connection_rate = v.connection_rate / v.rrc_and_e_rab_node_count
            v.unconnected_rate = v.unconnected_rate / v.rrc_and_e_rab_node_count
            v.dropout_rate = v.dropout_rate / v.rrc_and_e_rab_node_count

    def __getitem__(self, item):
        return getattr(self, item)

    def __setitem__(self, key, value):
        setattr(self, key, value)

    def __str__(self):
        str_out = ''
        for key, value in self.__dict__.items():
            str_out += f'{key}: {value}\n'

        return str_out
